import {App} from "vue";
import {sessionUtl} from "./sessionUtl";
import {localUtl} from "./localUtl";
import http from "./http";
import {deepCopy, keInList} from "./comFn";
import {checkFileSize, getLocalFile, valiteImgWh} from "./localFile";

/**
 * 注册全局工具方法
 * @param app 应用实例
 */
export const setUtls = (app: App) => {
    // 注入session缓存方式
    app.config.globalProperties.sessionUtl = sessionUtl;
    // 注入local缓存方式
    app.config.globalProperties.localUtl = localUtl;
    // 挂载http数据请求方法
    app.config.globalProperties.http = http;
    // 数据拷贝
    app.config.globalProperties.deepCopy = deepCopy;
    // 数组中存在某一数据
    app.config.globalProperties.keyInList = keInList;
    // 获取本地文件
    app.config.globalProperties.getLocalFile = getLocalFile;
    // 校验文件大小
    app.config.globalProperties.checkFileSize = checkFileSize;
    // 校验文件宽高
    app.config.globalProperties.valiteImgWh = valiteImgWh;
};